﻿using Microsoft.AspNetCore.Mvc;
using MiniFox.Components;
using MiniFox.Infrastructure;
using MiniFox.Platform;
using MiniFox.Utility;
using MiniFox.Web.Filters;
using MiniFox.Web.Infrastructure;
using Repository.Core.Models.Dto;
using Repository.Core.Models.Queries;
using Repository.Core.Models.VO;
using Repository.Core.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Repository.Core.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [NoCache, ValidationFilter]
    public class RepositoryController : MvcControllerBase
    {
        [AutoWired]
        public IRepositoryService Component { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<ResultObject<IEnumerable<RepositorySetVo>>> Query([FromBody] PagedQueryObject<CommonQuery> request)
        {
            var result = this.Component.Query(request);

            return result.CreateResponse();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<RepositorySetVo> Save([FromBody] RepositorySetDto dto)
        {
            RepositorySetVo vo = this.Component.Save(dto);
            return vo.CreateResponse();
        }
    }
}
